package com.imchen.cms.cmscore.service;

import com.imchen.cms.cmscore.dao.ArticleTypeMapper;
import com.imchen.cms.cmscore.model.ArticleType;
import com.imchen.cms.exception.CmsException;
import com.imchen.cms.utils.ServiceUtil;
import org.springframework.beans.factory.annotation.Autowired;


import org.springframework.stereotype.Service;

import java.util.HashMap;

/**
 * @author imchen
 * @create: 2019-01-12 10:53
 **/
@Service
public class ArticleTypeService implements BaseService<ArticleType> {

    @Autowired
    private ArticleTypeMapper mapper;

    @Override
    public HashMap<String, Integer> add(ArticleType articleType) throws CmsException {
        int count = mapper.insertSelective(articleType);
        int id = articleType.getId();
        return ServiceUtil.toAddMap(count, id);
    }

    @Override
    public ArticleType findById(int id) {
        return mapper.selectByPrimaryKey(id);
    }

    @Override
    public int removeById(int id) {
        return mapper.deleteByPrimaryKey(id);
    }

    @Override
    public int deleteById(int id) {
        return 0;
    }

    @Override
    public int update(ArticleType articleType) {
        return mapper.updateByPrimaryKeySelective(articleType);
    }
}